home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 3 / Info_Mac_1994-01.iso / Development / Source / MSG Graphic Effects 1.0 Source / Rescue Raiders.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-08-23  |  2.7 KB  |  89 lines  |  [TEXT/KAHL]

  1. /*******************************************************************************
  2.  * Copyright © 1992-1993 Mark Pilgrim                                          *
  3.  *                                                                             *
  4.  * This file is provided as is, and may be freely distributed unaltered.  This *
  5.  * message must accompany any copy of this file.  This file may be used or     *
  6.  * modified for use for a non-commercial product provided that appropriate     *
  7.  * credit is given to the author named above.                                  *
  8.  * Commercial use of this source code is prohibited.                           *
  9.  ******************************************************************************/
  10.  
  11. #include "msg misc.h"
  12. #include "msg timing.h"
  13.  
  14. #define NUMREGIONS 25
  15. #define BlockSize 10
  16. #define CorrectTime 5
  17.  
  18. void RescueRaiders(GrafPtr);
  19.  
  20. /* One region in 8 parts.  Each part of the region either starts at a corner
  21.    or in the middle of a side and moves progressively clockwise until the
  22.    entire screen is filled. Named after a similar effect in the game Rescue
  23.    Raiders on the Apple ][e (now called Armor Alley™ on the Mac, but it doesn't
  24.    have this effect in it anymore). */
  25.    
  26. void RescueRaiders(GrafPtr sourceGrafPtr)
  27. {
  28.     RgnHandle    curregion;
  29.     Rect        source;
  30.     int            cx,cy,lastx,lasty,VBlockSize;
  31.     
  32.     cx = (gMainWindow->portRect.right + gMainWindow->portRect.left) / 2;
  33.     cy = (gMainWindow->portRect.bottom + gMainWindow->portRect.top) / 2;
  34.     VBlockSize=BlockSize*MAIN_WINDOW_HEIGHT/MAIN_WINDOW_WIDTH;
  35.  
  36.     source.top=source.left=0;
  37.     source.bottom=MAIN_WINDOW_HEIGHT;
  38.     source.right=MAIN_WINDOW_WIDTH;
  39.     
  40.     lasty=lastx=0;
  41.     curregion=NewRgn();
  42.     do
  43.     {
  44.         StartTiming();
  45.  
  46.         SetEmptyRgn(curregion);
  47.         MoveTo(cx,cy);
  48.         OpenRgn();
  49.             LineTo(lastx,0);
  50.             Line(BlockSize,0);
  51.             LineTo(MAIN_WINDOW_WIDTH-lastx-BlockSize,MAIN_WINDOW_HEIGHT);
  52.             Line(BlockSize,0);
  53.             LineTo(cx,cy);
  54.             
  55.             LineTo(cx+lastx,0);
  56.             Line(BlockSize,0);
  57.             LineTo(cx-lastx-BlockSize,MAIN_WINDOW_HEIGHT);
  58.             Line(BlockSize,0);
  59.             LineTo(cx,cy);
  60.             
  61.             LineTo(MAIN_WINDOW_WIDTH,lasty);
  62.             Line(0,VBlockSize);
  63.             LineTo(0,MAIN_WINDOW_HEIGHT-lasty-VBlockSize);
  64.             Line(0,VBlockSize);
  65.             LineTo(cx,cy);
  66.             
  67.             LineTo(MAIN_WINDOW_WIDTH,cy+lasty);
  68.             Line(0,VBlockSize);
  69.             LineTo(0,cy-lasty-VBlockSize);
  70.             Line(0,VBlockSize);
  71.             LineTo(cx,cy);
  72.         CloseRgn(curregion);
  73.  
  74.         CopyBits(&(sourceGrafPtr->portBits), &(gMainWindow->portBits),
  75.             &source, &source, 0, curregion);
  76.  
  77.         lastx+=BlockSize;
  78.         lasty+=VBlockSize;
  79.  
  80.         TimeCorrection(CorrectTime);
  81.     }
  82.     while (lastx<cx);
  83.     
  84.     CopyBits(&(sourceGrafPtr->portBits), &(gMainWindow->portBits),
  85.         &source, &source, 0, 0L);   /* in case we missed any bits */
  86.     
  87.     DisposeRgn(curregion);
  88. }
  89.